<%@ include file="../../inc/init.jsp" %>

<html>
	<head>
		<title>
			Graduate Admission System | University of California - San Diego | 
			GRE Admin 
		</title>
		<link type="text/css" rel="stylesheet" href="<%= BASE %>css/main.css">
		<script type="text/javascript" src="<%= BASE %>js/msg.js"></script>
	</head>
	<body <%

		/** Show javascript message if msg parameter is set **/
	
		if(request.getParameter("msg") != null)
		{
			int msg = Integer.parseInt(request.getParameter("msg"));
			out.println("onload = \"info(" + msg + ", 6, " + BASE + ")\"");
		}
	%>>
		<div class="header-top"></div>
		<div class="header">
			<a href="<%= BASE %>admin/index.jsp"><img src="<%= BASE %>img/logo.png"></a>
		</div>
		<div class="content">
		
		<table>
		<tr><td><a href="<%= BASE %>admin/index.jsp">
			<img src="<%= BASE %>img/home.png"></a>&nbsp;&nbsp;
			</td>
			<td><span style="color: #515151;">You are logged in as: <b><%= request.getRemoteUser() %></b></span>&nbsp;</td>
			<td><a href="<%= BASE %>logout.jsp?page=admin">
				<img src="<%= BASE %>img/logout.png"></a>
			</td>
		</tr>
		</table>
		
		<div id="message"></div>
		
		<%
			/** Show GRE form if user has role chair otherwise redirect **/
		
			if(request.isUserInRole("chair"))
			{
				out.print("<h2>GRE</h2>" +
						  "Please fill out the form bellow to enter an new GRE.<br><br>");
				
		%>
		
		<form method="POST" action="writeGreToDb.jsp">
			<table>
				<tr>
					<td>Applicant:</td>
					<td colspan="2">
						<select name="applicant">
							<%
								ArrayList<HashMap<String, String>> al = Applications.getOverview();
								HashMap<String, String> hm = new HashMap<String, String>();
								
								/** Display all applicants in dropdown **/
								
								for(int i = 0; i < al.size(); i++)
								{
									hm = al.get(i);
					
									out.print("<option value=\"" + hm.get("id") + "\">" + hm.get("name") + 
										  	", " + hm.get("first_name")  + "</option>");
								}
							%>
						</select>
					</td>
				</tr>	
				<tr>
					<td>Analytical Writing:</td>
					<td><input name="analytical" size="4"> Score</td>
					<td><input name="analyticalPercent" size="4"> %</td>
				</tr>
				<tr>
					<td>Verbal Reasoning:</td>
					<td><input name="verbal" size="4"> Score</td>
					<td><input name="verbalPercent" size="4"> %</td>
				</tr>
				<tr>
					<td>Quantitative Reasoning:</td>
					<td><input name="quantitative" size="4"> Score</td>
					<td><input name="quantitativePercent" size="4"> %</td>
				</tr>
				<tr>
					<td>Total:</td>
					<td><input name="total" size="4"> Score</td>
					<td><input name="totalPercent" size="4"> %</td>
				</tr>
				<tr>
					<td>Type:</td>
					<td colspan="2">
						<select name="type">
							<option>Computer-based</option>
							<option>Paper-based</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>Month/Year:</td>
					<td><input name="month" size="4">/</td>
					<td><input name="year" size="4"></td>
				</tr>
				<tr>
					<td>Registration No.:</td>
					<td colspan="2"><input name="regNo"></td>
				</tr>
				<tr>
					<td colspan="3" align="right"><input type="submit" value="Submit"></td>
				</tr>
			</table>
		</form>
		<%
			}
			else
			{
				response.sendRedirect(BASE + "admin/index.jsp");
			}
		
		%>
		</div>
	</body>
</html>